package testPaperJBFX;

import android.animation.Animator;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.text.Html;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.lancooznbk.R;
import com.example.lancooznbk.utils.DialogHelper;
import com.example.lancooznbk.view.base.BaseFragment;

import java.util.ArrayList;

import lancooControl.AnimUtil;
import lancooControl.AnswerViewPagerAdapter;
import lancooCustomListview.BounceListView;
import lancooPaperAnswer.AnswerTktAdapter;
import lancooPaperAnswer.AnswerTljdAdapter;
import lancooPaperAnswer.AnswerXztAdapter;
import lancooPaperAnswer.AnswerYdjdAdapter;
import lancooPaperContent.ContentDxtAdapter;
import lancooPaperContent.ContentTktAdapter;
import lancooPaperContent.ContentTljdAdapter;
import lancooPaperContent.ContentTltkAdapter;
import lancooPaperContent.ContentTlxzAdapter;
import lancooPaperContent.ContentXztAdapter;
import lancooPaperContent.ContentYdjdAdapter;
import lancooPaperContent.ContentZgtAdapter;
import lancooPaperContent.WrapBaseAdapter;
import lancooPaperRateSelf.RateTktAdapter;
import lancooPaperRateSelf.RateTljdAdapter;
import lancooPaperRateSelf.RateYdjdAdapter;
import lancooPaperRateSelf.RateZgtAdapter;

import static testPaperJBFX.BasicReviewPaperActivity.InforBasicReview;
import static testPaperJBFX.BasicReviewPaperActivity.PAPER_FROM;

//import lancooPaperContent.ContentYyzAdapter;

/**
 * 用于创建Fragment对象，作为ViewPager的叶片
 * @author WGL
 *
 */
public class BasicReviewPaperFragment extends BaseFragment {
    /*****************************************/
//    //private Button btn_move;//可拖动按钮
//    private boolean clickormove = true;//点击或拖动，点击为true，拖动为false
//    private int downX, downY;//按下时的X，Y坐标
//    private boolean hasMeasured = false;//ViewTree是否已被测量过，是为true，否为false
//    private View content;//界面的ViewTree
//    private int screenWidth,screenHeight;//ViewTree的宽和高
    /*****************************************/
    private int mNum; //页号

    private ArrayList<View> list;
    private TextView TvContentType;//题目简介
    private BounceListView LvContent;//试题主干部分
    //private RelativeLayout mRelContent;
    private TextView TvContentNumber;//
//    private TextView TvAnswerAmount;
    public  ViewPager VpAnswer;
    private WrapBaseAdapter mAdapter;
    //private RelativeLayout RLayoutAnswerMenu;

    private LinearLayout LayoutSelfRate;
    //private RelativeLayout RLayoutAnswer;
    private int state = 0;//试卷作答状态

    private View relContainer;

    public static int currentSmallViewPage;
    private int rateID;
    private int layoutId;

    private int mModelFrom;
    private FrameLayout mFlLoading;


    public static BasicReviewPaperFragment newInstance(int num) {
        BasicReviewPaperFragment fragment = new BasicReviewPaperFragment();
        // Supply num input as an argument.
        Bundle args = new Bundle();
        args.putInt("num", num);
        fragment.setArguments(args);
        return fragment;
    }



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //这里我只是简单的用num区别标签，其实具体应用中可以使用真实的fragment对象来作为叶片
        mNum = getArguments() != null ? getArguments().getInt("num") : 1;
        mModelFrom = getHolderActivity().getIntent().getIntExtra(PAPER_FROM,0);
        rateID = 0;
        currentSmallViewPage = 0;
    }

    @Override
    protected void updateViews(boolean isShowLoading) {
        if(getQuesType(mNum).equals("作文")||getQuesType(mNum).equals("看图写句子")||getQuesType(mNum).equals("翻译题")){
            showCommonTesePaper(false);
            showSelfRate(true);
        }else if(getQuesType(mNum).equals("词汇填空")||getQuesType(mNum).equals("阅读填空")||getQuesType(mNum).equals("句子填空")||
                getQuesType(mNum).equals("翻译填空")||getQuesType(mNum).equals("短文填空")||getQuesType(mNum).equals("听力填空")){
            showCommonTesePaper(true);
            //initMoveRLayout();
            showSelfRate(true);
        }else if(getQuesType(mNum).equals("听力选择")||getQuesType(mNum).equals("阅读选择")||getQuesType(mNum).equals("阅读判断")||
                getQuesType(mNum).equals("完形选择")||getQuesType(mNum).equals("匹配题")){
            showCommonTesePaper(true);
            //initMoveRLayout();
            showSelfRate(false);
        }else if(getQuesType(mNum).equals("单选题")){
            showCommonTesePaper(false);
            showSelfRate(false);
        }else if(getQuesType(mNum).equals("阅读简答")||getQuesType(mNum).equals("听力简答")){
            showCommonTesePaper(true);
            //initMoveRLayout();
            showSelfRate(true);
        }

        relContainer.post(new Runnable() {
            @Override
            public void run() {
                mFlLoading.setVisibility(View.GONE);
                if (layoutId == R.layout.paper_zgt||layoutId == R.layout.paper_dxt) {
                    DialogHelper.showGuideOne(getHolderActivity());
                    // DialogHelper.showPopup(GuessTestingPaperFragment.this);
                }else{
                    DialogHelper.showGuideTwo(getHolderActivity());
                }
            }
        });

    }

    @Override
    public int attachLayoutRes() {
        if(getQuesType(mNum).equals("作文")||getQuesType(mNum).equals("看图写句子")||getQuesType(mNum).equals("翻译题")){
            layoutId = R.layout.paper_zgt;
        }else if(getQuesType(mNum).equals("词汇填空")||getQuesType(mNum).equals("阅读填空")||getQuesType(mNum).equals("句子填空")||
                getQuesType(mNum).equals("翻译填空")||getQuesType(mNum).equals("短文填空")||getQuesType(mNum).equals("听力填空")){
            layoutId =  R.layout.paper_tkt;
        }else if(getQuesType(mNum).equals("听力选择")||getQuesType(mNum).equals("阅读选择")||getQuesType(mNum).equals("阅读判断")||
                getQuesType(mNum).equals("完形选择")||getQuesType(mNum).equals("匹配题")){
            layoutId =  R.layout.paper_xzt;
        }else if(getQuesType(mNum).equals("单选题")){
            layoutId =  R.layout.paper_dxt;
        }

        else if(getQuesType(mNum).equals("听力简答")){
            layoutId =  R.layout.paper_tljd;
        }else if(getQuesType(mNum).equals("阅读简答")){
            layoutId =  R.layout.paper_ydjd;
        }
        return layoutId;
    }


    @Override
    public void initViews(View view, Bundle savedInstanceState) {
        state = InforBasicReview.getState();
        Log.e("===111111===888888==", String.valueOf(state));
        mFlLoading = (FrameLayout) view.findViewById(R.id.fl_ques_loading);
        relContainer = (View) view.findViewById(R.id.common_main);
        LayoutSelfRate = (LinearLayout) view.findViewById(R.id.layout_self_rate);
        TvContentType = (TextView) view.findViewById(R.id.textview_content_type);
        TvContentNumber = (TextView) view.findViewById(R.id.textview_content_number);
        LvContent = (BounceListView) view.findViewById(R.id.listview_content);
        //mRelContent = (RelativeLayout) view.findViewById(R.id.rel_content);

        VpAnswer = (ViewPager) view.findViewById(R.id.viewpage_answer);
        //RLayoutAnswer = (RelativeLayout) view.findViewById(R.id.rlayout_answer);
        //RLayoutAnswerMenu = (RelativeLayout) view.findViewById(R.id.rlayout_answer_menu);
      /*  WindowManager wm = (WindowManager) getContext().getSystemService(getContext().WINDOW_SERVICE);
        int width = wm.getDefaultDisplay().getWidth();
        int height = wm.getDefaultDisplay().getHeight();
        RelativeLayout.LayoutParams rlayoutParams = (RelativeLayout.LayoutParams) RLayoutAnswer.getLayoutParams();
        rlayoutParams.height = height/2;
        rlayoutParams.width = width;
        RLayoutAnswer.setLayoutParams(rlayoutParams);*/
        //btn_move = (Button) view.findViewById(R.id.button_move);

        /*
        * 题目简介(试题)
        * */
        TvContentType.setText(InforBasicReview.getPaperName());
        /*
        * 匹配题目小题数分布
        * */
//        TvContentNumber.setText(Html.fromHtml("<font color='#45a1cf'><big><big>"+(mNum+1)+"</big></big></font>"+"/"+getQusSum()));
        TvContentNumber.setText(Html.fromHtml("<font color='#3399cc'>"+(mNum+1)+"</font>"+"/"+"<font color='#686868'>"+getQusSum()+"</font>"));

    }


    /*
    *@@@显示自评区域
    * */
    private void showSelfRate(boolean isShow){

        if(isShow) {
            if (state != 2) {

                LayoutSelfRate.setVisibility(View.VISIBLE);
                LayoutSelfRate.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        animUtil = new AnimUtil();
                        bottomwindow(LayoutSelfRate, mNum);
                        toggleBright();
                    }
                });
            } else {
                LayoutSelfRate.setVisibility(View.GONE);
            }
        }else{
            LayoutSelfRate.setVisibility(View.GONE);
        }
    }

    /*
    * @@显示试卷主体
    * 实现试卷界面的布局展示
    * */
    private void showCommonTesePaper(boolean bShowChildViewPager){

//        /*
//        * 题目简介(试题)
//        * */
//        TvContentType.setText(InforBasicReview.getPaperName());

//        /*
//        * 匹配题目小题数分布
//        * */
//        TvContentNumber.setText(Html.fromHtml("<font color='#45a1cf'><big><big>"+(mNum+1)+"</big></big></font>"+"/"+getQusSum()));


         /*
        * 试题主干显示区
        * */
        if(getQuesType(mNum).equals("作文")||getQuesType(mNum).equals("看图写句子")||getQuesType(mNum).equals("翻译题")){
            mAdapter = new ContentZgtAdapter(getActivity(), 1, mNum,mModelFrom);
        }else if(getQuesType(mNum).equals("词汇填空")||getQuesType(mNum).equals("阅读填空")||getQuesType(mNum).equals("句子填空")||
                getQuesType(mNum).equals("翻译填空")||getQuesType(mNum).equals("短文填空")){
            mAdapter = new ContentTktAdapter(getActivity(),1,mNum,mModelFrom);
        }else if(getQuesType(mNum).equals("听力填空")){
            mAdapter = new ContentTltkAdapter(getActivity(), 1, mNum,mModelFrom);
        }else if(getQuesType(mNum).equals("阅读选择")||getQuesType(mNum).equals("阅读判断")|| getQuesType(mNum).equals("完形选择")||
                getQuesType(mNum).equals("匹配题")){
            mAdapter = new ContentXztAdapter(getActivity(),1,mNum,mModelFrom);
        }else if(getQuesType(mNum).equals("听力选择")){
            mAdapter = new ContentTlxzAdapter(getActivity(),1,mNum,mModelFrom);
        }else if(getQuesType(mNum).equals("单选题")) {
            mAdapter = new ContentDxtAdapter(getActivity(), 1, mNum,mModelFrom);
        }
        else if(getQuesType(mNum).equals("听力简答")){
            mAdapter = new ContentTljdAdapter(getActivity(),1,mNum,mModelFrom);
        }else if(getQuesType(mNum).equals("阅读简答")){
            mAdapter = new ContentYdjdAdapter(getActivity(),1,mNum,mModelFrom);
        }
        LvContent.setAdapter(mAdapter);
        LvContent.setPadding(0,0,0,0);

        if(bShowChildViewPager) {

//            /*
//            *答题区小题数量
//            * */
//            TvAnswerAmount.setText("本题包含"+getSubjectSum(mNum)+"个小题");
            /*
            * 答题区
            * */
            list = new ArrayList<View>();
            list.clear();
            int sumSubject = getSubjectSum(mNum);
            for (int k = 0; k < sumSubject; k++) {

                BounceListView LvAnswer = new BounceListView(getActivity());
                if(getQuesType(mNum).equals("词汇填空")||getQuesType(mNum).equals("阅读填空")||getQuesType(mNum).equals("句子填空")||
                        getQuesType(mNum).equals("翻译填空")||getQuesType(mNum).equals("短文填空")||getQuesType(mNum).equals("听力填空")){
                    LvAnswer.setAdapter(new AnswerTktAdapter(getActivity(),1,mNum,k,mModelFrom));
                }else if(getQuesType(mNum).equals("听力选择")||getQuesType(mNum).equals("阅读选择")||getQuesType(mNum).equals("阅读判断")||
                        getQuesType(mNum).equals("完形选择")||getQuesType(mNum).equals("匹配题") ){
                    LvAnswer.setAdapter(new AnswerXztAdapter(getActivity(),1,mNum,k,mModelFrom));
                }
                else if(getQuesType(mNum).equals("听力简答")){
                    LvAnswer.setAdapter(new AnswerTljdAdapter(getActivity(),1,mNum,k,mModelFrom));
                }else if(getQuesType(mNum).equals("阅读简答")){
                    LvAnswer.setAdapter(new AnswerYdjdAdapter(getActivity(),1,mNum,k,mModelFrom));
                }
                /*
                *答题区小题数量
                * */
//                TvAnswerAmount = (TextView) LvAnswer.findViewById(R.id.tv_answer_amount);
//                TvAnswerAmount.setText("本题包含"+getSubjectSum(mNum)+"个小题");
                list.add(LvAnswer);
            }

            VpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
            VpAnswer.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                @Override
                public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

                }

                @Override
                public void onPageSelected(int position) {
                    //此处添加父页面操作事件
                    rateID = position;
                    currentSmallViewPage = position;
                }

                @Override
                public void onPageScrollStateChanged(int state) {

                }
            });
        }


    }

    /*
    * 实现滑块的上下移动
    * */
    /*private void initMoveRLayout(){
        *//*************************************************************************************************************//*
//        final RelativeLayout RLayoutAnswer = (RelativeLayout) view.findViewById(R.id.rlayout_answer);

        content =  getActivity().getWindow().findViewById(Window.ID_ANDROID_CONTENT);//获取界面的ViewTree根节点View

        DisplayMetrics dm = getResources().getDisplayMetrics();//获取显示屏属性
        screenWidth = dm.widthPixels;
        screenHeight = dm.heightPixels;
        ViewTreeObserver vto = content.getViewTreeObserver();//获取ViewTree的监听器
        vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                // TODO Auto-generated method stub
                if(!hasMeasured)
                {
                    screenHeight = content.getMeasuredHeight();//获取ViewTree的高度
                    hasMeasured = true;//设置为true，使其不再被测量。
                }
                return true;//如果返回false，界面将为空。
            }
        });
//        btn_move = (Button) view.findViewById(R.id.button_move);
        btn_move.setOnTouchListener(new View.OnTouchListener() {//设置按钮被触摸的时间
            int lastX, lastY; // 记录移动的最后的位置
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                int ea = event.getAction();//获取事件类型
                switch (ea) {
                    case MotionEvent.ACTION_DOWN: // 按下事件
                        lastX = (int) event.getRawX();
                        lastY = (int) event.getRawY();
                        downX = lastX;
                        downY = lastY;
                        break;
                    case MotionEvent.ACTION_MOVE: // 拖动事件
                        // 移动中动态设置位置
                        int dx = (int) event.getRawX() - lastX;//位移量X
                        int dy = (int) event.getRawY() - lastY;//位移量Y

                        Log.e("asa", "onTouch: ==============="+dy);
                        //int left = v.getLeft() + dx;
                        int left = v.getLeft();
                        int top = v.getTop() + dy;
                        //int right = v.getRight() + dx;
                        int right = v.getRight();
                        int bottom = v.getBottom() + dy;
                        //++限定按钮被拖动的范围
                        if (left < 0) {
                            left = 0;
                            right = left + v.getWidth();
                        }
                        if (right > screenWidth) {
                            right = screenWidth;
                            left = right - v.getWidth();
                        }
                        if (top < 0) {
                            top = 0;
                            bottom = top + v.getHeight();
                        }
                        if (bottom > screenHeight) {
                            bottom = screenHeight;
                            top = bottom - v.getHeight();
                        }
                        //--限定按钮被拖动的范围
                        v.layout(left, top, right, bottom);//按钮重画

                        RelativeLayout.LayoutParams Params =(RelativeLayout.LayoutParams) RLayoutAnswer.getLayoutParams(); //取控件当前的布局参数
                        Params.height = Math.min(RLayoutAnswerMenu.getHeight() - DensityUtils.dp2px(getActivity(),40),Params.height - dy);


                        int minHeight = Control.dip2px(getActivity(),30);
                        if(Params.height < minHeight) {
                            Params.height = minHeight;
                        }

                        Log.e("===WWWheight==","=========="+LvContent.getHeight());


                        System.out.println(screenHeight+"=======Params.height======="+Params.height);
                        RLayoutAnswer.setLayoutParams(Params); //使设置好的布局参数应用到控件
                        mRelContent.requestLayout();

                        // 记录当前的位置
                        lastX = (int) event.getRawX();
                        lastY = (int) event.getRawY();
                        System.out.println("=======lastX======="+lastX+"=======lastY====="+lastY);
                        break;
                    case MotionEvent.ACTION_UP: // 弹起事件
                        //判断是单击事件或是拖动事件，位移量大于5则断定为拖动事件
                        if (Math.abs((int) (event.getRawX() - downX)) > 5
                                || Math.abs((int) (event.getRawY() - downY)) > 5)
                            clickormove = false;
                        else
                            clickormove = true;
                        break;
                }
                return false;
            }
        });
//        btn_move.setOnClickListener(new View.OnClickListener() {//设置按钮被点击的监听器
//            @Override
//            public void onClick(View arg0) {
//// TODO Auto-generated method stub
//                if (clickormove)
//                    Toast.makeText(getActivity(), "single click",
//                            Toast.LENGTH_SHORT).show();
//            }
//        });
        *//*************************************************************************************************************//*
    }*/


    /*****************************************查看答案及自评*****************************************************/
    private AnimUtil animUtil;
    private float bgAlpha = 1f;
    private boolean bright = false;
    PopupWindow popupWindow;
    private LinearLayout LayoutRateSelfOpen;
    private BounceListView lv_answer_rate;
    private void toggleBright() {
        //三个参数分别为： 起始值 结束值 时长  那么整个动画回调过来的值就是从0.5f--1f的
        animUtil.setValueAnimator(0.5f, 1f, 350);
        animUtil.addUpdateListener(new AnimUtil.UpdateListener() {
            @Override
            public void progress(float progress) {
                //此处系统会根据上述三个值，计算每次回调的值是多少，我们根据这个值来改变透明度
                bgAlpha = bright ? progress : (1.5f - progress);//三目运算，应该挺好懂的。
                backgroundAlpha(bgAlpha);//在此处改变背景，这样就不用通过Handler去刷新了。
            }
        });
        animUtil.addEndListner(new AnimUtil.EndListener() {
            @Override
            public void endUpdate(Animator animator) {
                //在一次动画结束的时候，翻转状态
                bright = !bright;
            }
        });
        animUtil.startAnimator();
    }

    /***
     * 此方法用于改变背景的透明度，从而达到“变暗”的效果
     */
    private void backgroundAlpha(float bgAlpha) {
        WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
        lp.alpha = bgAlpha; //0.0-1.0
        getActivity().getWindow().setAttributes(lp);
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    }


    /*
    * 实现自评展示区
    * */
    void bottomwindow(final View view,int paperID) {
        if (popupWindow != null && popupWindow.isShowing()) {
            return;
        }
        RelativeLayout RLayout = (RelativeLayout) getActivity().getLayoutInflater().inflate(R.layout.pop_rate_self, null);

        popupWindow = new PopupWindow(RLayout,
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        //点击空白处时，隐藏掉pop窗口
        popupWindow.setFocusable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());

        popupWindow.setAnimationStyle(R.style.Popupwindow);
        int[] location = new int[2];
        view.getLocationOnScreen(location);
        popupWindow.showAtLocation(view, Gravity.LEFT | Gravity.BOTTOM, 0, -location[1]);
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                toggleBright();
            }
        });

        LayoutRateSelfOpen = (LinearLayout) RLayout.findViewById(R.id.layout_self_rate_open);
        LayoutRateSelfOpen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });

        lv_answer_rate = (BounceListView) RLayout.findViewById(R.id.listview_answer_rate);

        if(getQuesType(mNum).equals("作文")||getQuesType(mNum).equals("看图写句子")||getQuesType(mNum).equals("翻译题")){
            lv_answer_rate.setAdapter( new RateZgtAdapter(getActivity(), 1,paperID,mModelFrom));
        }else if(getQuesType(mNum).equals("词汇填空")||getQuesType(mNum).equals("阅读填空")||getQuesType(mNum).equals("句子填空")||
                getQuesType(mNum).equals("翻译填空")||getQuesType(mNum).equals("短文填空")||getQuesType(paperID).equals("听力填空")){
            lv_answer_rate.setAdapter(new RateTktAdapter(getActivity(), 1,paperID,rateID,mModelFrom));
        }

        else if(getQuesType(paperID).equals("听力简答")) {
            lv_answer_rate.setAdapter(new RateTljdAdapter(getActivity(), 1,paperID,rateID,mModelFrom));
        }else if(getQuesType(paperID).equals("阅读简答")) {
            lv_answer_rate.setAdapter(new RateYdjdAdapter(getActivity(), 1,paperID,rateID,mModelFrom));
        }

    }

/**********************************************************************************************/

    /*
    *获取题型
    * */
      /*
    *获取题型
    * f：作文  大Z：听力简答  大S：听力填空  E：听力选择  大X：阅读简答  D：阅读选择  K：阅读判断  Q：阅读填空
    * m：匹配题  大C：完形选择  大O：句子填空   g：翻译题   d：看图写句子  A；单选题
    * N:词汇填空
    * */
    private String getQuesType(int postion){
        String strTypeID = InforBasicReview.getPaperContent().get(postion).getTypeID();
        String strQuesTypeName = "";
        if(strTypeID.equals("f")){
            strQuesTypeName = "作文";
        }else if(strTypeID.equals("Z")){
            strQuesTypeName = "听力简答";
        }else if(strTypeID.equals("S")){
            strQuesTypeName = "听力填空";
        }else if(strTypeID.equals("E")){
            strQuesTypeName = "听力选择";
        }else if(strTypeID.equals("X")){
            strQuesTypeName = "阅读简答";
        }else if(strTypeID.equals("D")){
            strQuesTypeName = "阅读选择";
        }else if(strTypeID.equals("K")){
            strQuesTypeName = "阅读判断";
        }else if(strTypeID.equals("Q")){
            strQuesTypeName = "阅读填空";
        }else if(strTypeID.equals("m")){
            strQuesTypeName = "匹配题";
        }else if(strTypeID.equals("C")){
            strQuesTypeName = "完形选择";
        }else if(strTypeID.equals("O")){
            strQuesTypeName = "句子填空";
        }else if(strTypeID.equals("g")){
            strQuesTypeName = "翻译题";
        }else if(strTypeID.equals("d")){
            strQuesTypeName = "看图写句子";
        }else if(strTypeID.equals("A")){
            strQuesTypeName = "单选题";
        }else if(strTypeID.equals("T")){
            strQuesTypeName = "翻译填空";
        }else if(strTypeID.equals("P")){
            strQuesTypeName = "短文填空";
        }else if(strTypeID.equals("N")){
            strQuesTypeName = "词汇填空";
        }
        return  strQuesTypeName;
    }

    /*
    * 获取试卷总页数
    * */
    private int getQusSum(){
        return InforBasicReview.getPaperContent().size();
    }

    /*
    * 获取题目对应的小题数目(显示页数)
    * */
    private int getSubjectSum(int position){
        int sumSubject = -1;
//        if(getQuesType(position).equals("阅读填空")||getQuesType(position).equals("听力填空")||
//                getQuesType(position).equals("句子填空")||getQuesType(position).equals("短文填空")||getQuesType(position).equals("词汇填空")){
//            sumSubject = 1;
//        }else{
//            sumSubject = InforBasicReview.getPaperContent().get(position).getQueList().size();
//        }

        sumSubject = InforBasicReview.getPaperContent().get(position).getQueList().size();

        return sumSubject;
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (!isVisibleToUser && mAdapter != null){//可见时进行调用
            mAdapter.pause();
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        if (mAdapter != null){//不可见 暂停音乐播放
            mAdapter.pause();
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mAdapter != null){//不可见 暂停音乐播放
            mAdapter.pause();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mAdapter != null) {
            mAdapter.stop();

        }
    }



}